package action.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import biz.NewsBiz;
import biz.impl.NewsBizImpl;
import entity.News;


public class NewsListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public NewsListServlet() {
        super();
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		NewsBiz nb = new NewsBizImpl();
		if(request.getParameter("nid")!=null){
			int nid = Integer.parseInt(request.getParameter("nid"));
			nb.deletenews(nid);
		}
		String s = request.getParameter("search");
		List<News> newslist =nb.getNewsBySearch(s);
		request.setAttribute("newslist", newslist);
		request.getRequestDispatcher("/admin/newsList.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	}

}
